<!-- 目录 -->
<template>
    <div class="outer" @scroll="handleScroll">
        <!-- 用户 -->
        <div class="list" v-for="(item, index) in list" :key="index" @click="goPage('/columnIndex', item.col_id)">
            <div class="img">
                <img :src="item.thumb" alt="">
            </div>
            <p class="line2">【{{ item.title }}】{{ item.intro }}</p>
            <div class="bom">

                    <div  @click="delTeams(item.id)" class="y2">
                        <span>解除协作</span>
                    </div>

            </div>
        </div>

    </div>
</template>
<script>
export default {
    data() {
        return {
            title: '',
            loading: true,
            price: '',
            checked: false,
            readOnly: true,
            checked1: false,
            value1: '第一回甄士隐梦幻识通灵贾雨村风尘怀闺秀',
            value2: 2,
            value3: 1,
            pageNum: 1,
            totalPage: 1,
            total: 0,
            new_id: 0,
            list: [],
            id: ''
        }
    },
    mounted() {
        window.addEventListener('scroll', this.handleScroll); // 监听滚动事件
        let id = this.$route.query.id
        console.log(id, '获取到的传参')
        if (id) {
            this.new_id = id
            this.pageNum = 1
        }
        this.getList()
    },
    beforeDestroy() {
        window.removeEventListener('scroll', this.handleScroll); // 移除监听
    },
    methods: {

        delTeams(apply_id) {
            this.$confirm('确定解除协作吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            let params = {
                apply_id,
                id: this.id != 0 ? this.id : this.new_id
            }
            this.$api.delTeams(params).then(res => {
                if (res.data.code == 1) {
                    this.$message({
                        message: res.data.msg,
                        type: 'success'
                    })
                    this.list = []
                    this.pageNum = 1
                    this.getList()
                }
            })
        }).catch(() => {
              
        });
           
        },
        getList() {
            this.loading = true
            let params = {
                page: this.pageNum,
                id: this.id != 0 ? this.id : this.new_id
            }
            this.$api.getTeams(params).then(res => {
                if (res.data.code == 1) {
                    this.totalPage = res.data.data.last_page
                    this.list = this.list.concat(res.data.data.data);
                    this.total = res.data.data.total
                    this.loading = false
                }

            })
        },
        handleScroll() {
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            const windowHeight = window.innerHeight;
            const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
            // 判断是否滚动到底部
            if (scrollTop + windowHeight >= scrollHeight) {
                this.load()
            }
        },
        load() {
            console.log('触底');

        },
        //跳页面
        goPage(id, url) {
            if (id) {
                this.$router.push({
                    path: url,
                    query: {
                        id
                    }
                })
            }
        }
    }
}
</script>
<style lang="scss" scoped>
.outer {
    // padding-left: 2.81rem;
    padding-right: 2px;
    height: 100%;
    overflow-y: auto;
    -ms-overflow-style: none;
    width: 100%;
    padding-bottom: 98px;

    &::-webkit-scrollbar {
        /*滚动条整体样式*/
        width: 0 !important;
        /*高宽分别对应横竖滚动条的尺寸*/
        height: 0 !important;
    }

    .list {
        cursor: pointer;
        width: 335px;
        margin-right: 19px;
        margin-bottom: 80px;
        border-radius: 10px;
        overflow: hidden;

        &:nth-child(4n) {
            margin-right: 0;
        }

        .img {
            width: 335px;
            height: 335px;
            justify-content: center;
            align-items: center;
            display: flex;
            flex-direction: column;
            border-radius: 5px;
            overflow: hidden;

            img {
                width: 330px;
                height: 330px;
                object-fit: cover;
            }

            i {
                font-size: 100px;
                color: #999;
                border: 1px dashed #999;
                margin-bottom: 39px;
            }

            span {
                font-weight: 400;
                font-size: 24px;
                color: #666666;
            }
        }

        >p {
            font-weight: 400;
            font-size: 18px;
            color: #000000;
            margin: 24px 0 20px;
        }

        .bom {
            display: flex;
            justify-content: space-between;
            align-items: center;

            .y2 {

                background-color: #e4e1e1;

                padding: 0 10px;

                >div {
                    display: flex;
                    align-items: center;
                }

                i {
                    font-size: 16px;
                    margin-right: 5px;
                }

                span {
                    font-size: 14px;
                    color: #999;
                }
            }

            .collect {
                font-weight: 400;
                font-size: 16px;
                color: #999999;
            }
        }
    }
}

.topHead {
    border-bottom: 0.05rem solid #E5E5E5 !important;
    position: sticky;
    top: 0rem;
    background-color: #fff;
    z-index: 22;

    .operate {
        display: flex;
        justify-content: center !important;
    }
}

.l-list {
    width: 100%;
    display: flex;
    height: 3.12rem;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 0.05rem dashed #E5E5E5;

    >div {
        display: flex;
        align-items: center;
        font-family: Microsoft YaHei;
        font-weight: 400;
        font-size: 1rem;
        color: #333333;
        height: 100%;

        box-sizing: border-box;
    }

    input {
        outline: none;
        height: 100%;
        font-family: Microsoft YaHei;
        font-weight: 400;
        font-size: 1rem;
        color: #333333;
        width: 100%;
        border: none;
        text-align: center;

    }

    .input {
        width: 33.85rem;

        input {
            text-align: left;
        }
    }

    .price {
        width: 4.63rem;

        input {
            text-align: center;

        }
    }

    .check {
        width: 2.08rem;
        display: flex;
        justify-content: center;
    }

    .sort {
        width: 3.4rem;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;

        >div {
            margin-left: 0.2rem;
            display: flex;
            flex-direction: column;

            i {
                &:first-child {
                    margin-bottom: -0.5rem;
                }
            }
        }
    }

    .operate {
        width: 8.33rem;
        justify-content: space-between;

        span {
            cursor: pointer;
        }
    }
}

.add {
    background-color: #fff;
    position: sticky;
    top: 3.12rem;
    z-index: 22;

    .operate {
        justify-content: center !important;
    }
}

.acs {
    display: flex;
}

.action {
    display: inline-flex;
    flex-direction: column;
    white-space: nowrap;
    font-size: 12px;

    span {
        color: #1068E7;
        display: inline-block;

    }

    >div {
        margin-bottom: 0.2rem;
    }

    &:nth-child(2) {
        margin-left: 0.2rem;

        div {
            padding-left: 0.2rem;
            border-left: 0.01rem solid #000;
        }
    }
}
@media screen and (max-width:768px) {
    .outer{
        .list{
            width: 100%;
            display: flex;
            // align-items: center;
            padding:10px;
            position: relative;
            .img{
                height: 150px;
                display: flex;
                width: 150px;
                align-items: flex-start;
                img{
                    height: 100%;
                    width: 150px;
                }
            }
            P{
                font-size: 16px;
                margin: 10px 20px;
            }
            .bom{
                position: absolute;
                left: 180px;
                bottom: 20px;
                .y2{
                    span{
                        font-size: 16px;
                        background-color: #1068E7;
                        color: #fff;
                        padding: 5px 10px;
                    }
                }
            }
        }
    }
}
</style>